import 'package:flutter/material.dart';

class ParentManagerState extends StatefulWidget {
  const ParentManagerState({super.key});

  @override
  _ParentManagerState createState() => _ParentManagerState();
}

class _ParentManagerState extends State<ParentManagerState> {
  bool _active = false;

  void _handleTapBoxChanged(bool newValue) {
    setState(() {
      _active = newValue;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: TapBox(active: _active, onChanged: _handleTapBoxChanged),
    );
  }
}

class TapBox extends StatelessWidget {
  final bool active;
  final ValueChanged<bool> onChanged;

  const TapBox({super.key, this.active = false, required this.onChanged});

  void _handleTap() {
    onChanged(!active);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("父管理状态")),
      body: GestureDetector(
        onTap: _handleTap,
        child: Container(
          width: 200.0,
          height: 200.0,
          decoration: BoxDecoration(
            color: active ? Colors.lightGreen[700] : Colors.grey[600],
          ),
          child: Center(
            child: Text(
              active ? 'Active' : 'Inactive',
              style: TextStyle(fontSize: 32.0, color: Colors.white),
            ),
          ),
        ),
      ),
    );
  }
}
